package game.fury;

import android.graphics.Canvas;
import android.graphics.Paint;
import sheep.game.Sprite;
import sheep.game.State;
import sheep.graphics.Font;
import sheep.graphics.Image;
import sheep.gui.TextButton;
import sheep.gui.WidgetAction;
import sheep.gui.WidgetListener;
import sheep.input.TouchListener;

public class PauseScreen extends State implements TouchListener, WidgetListener{
	
	private Image pause;
	private Sprite background;
	private TextButton play;
	private TextButton restart;
	private TextButton quit;
	
	/**
	 * Displays a pause screen with resume, reload, and quit buton.
	 * @author Marius Haugen
	 */
	public PauseScreen(){
		pause = new Image(R.drawable.pause_screen_340x545);
		background = new Sprite(pause);
//		background.setShape(300,480);
		background.setPosition(240, 400);
		
		play = new TextButton(120,350, "Press here to continue", new Paint[] {Font.WHITE_SANS_BOLD_20, Font.WHITE_SANS_BOLD_20} );
		addTouchListener(play);
		play.addWidgetListener(this);
		
		restart = new TextButton(130,450, "Press here to restart", new Paint[] {Font.WHITE_SANS_BOLD_20, Font.WHITE_SANS_BOLD_20} );
		addTouchListener(restart);
		restart.addWidgetListener(this);
		
		quit = new TextButton(140,550, "Press here to quit", new Paint[] {Font.WHITE_SANS_BOLD_20, Font.WHITE_SANS_BOLD_20} );
		addTouchListener(quit);
		quit.addWidgetListener(this);
		
		
	}
	
	
	public void draw(Canvas canvas){
		background.draw(canvas);
		play.draw(canvas);
		restart.draw(canvas);
		quit.draw(canvas);
	}
	
	public void update(float dt){
		background.update(dt);
	}


	@Override
	public void actionPerformed(WidgetAction action) {
		if(action.getSource().equals(play)) getGame().popState();
		if(action.getSource().equals(restart)){
			getGame().popState();
			getGame().popState();
			getGame().pushState(new FuryScreen(getGame(),1,0));
		}
		if(action.getSource().equals(quit)){
			getGame().popState();
			getGame().popState();
		}
		
	}

}
